#!/usr/bin/python 
#coding=utf-8

import time;
import logging;


print "hello world!\n "

print "你好，世界！\n "



#python元字典
dict={'name':'yangmengya','age':23,'work':'IT'}
print dict['name']
print dict
print dict.keys()
print dict.values()



#python循环语句
for ind in 'python':
    if ind=='o':
        continue
    print ind
print "For END"

sum=10
while  sum>0:
    sum-=1
    print sum
print "While END"


#python字符串
var1="hello world"
print var1[0]
print var1[1:4]
print var1 * 2



#python字典
dict={'name':'yangmengya','age':23,'work':'IT','school':'lishui'}

dict2={'xxx':'yyy'}
print "dict2=", dict2,"\n"

dict2.update(dict)
print "dict2=", dict2,"\n"



#Python日期
shijianchuo=time.time();
print "当前时间的时间戳形式表示:",shijianchuo,"\n"

shijianyuanzu=time.localtime(shijianchuo)
print "当前时间的时间元组形式表示：",shijianyuanzu,"\n"

geshihuashijian=time.asctime(shijianyuanzu)
print "简单时间格式化表示：",geshihuashijian,"\n"

geshihuariqi=time.strftime("%Y-%m-%d",shijianyuanzu)
print "日期格式化表示：",geshihuariqi,"\n"

shijianchuo=time.mktime(time.strptime(geshihuashijian,"%a %b %d %H:%M:%S %Y"))
print "将当前时间的字符串格式转换为时间戳形式表示",shijianchuo,"\n"



#python从键盘读取输入
#str=input("请输入：");
#print "你输入的内容是：",str,"\n"



#logging
logging.debug("This is debug message")
logging.info("This is info message")
logging.warning("This is warning message")


#python装饰器     
def deco(fun):
    print("before myfun() called")
    fun()
    print("after myfun() called\n")
    return fun

def myfun():
    print("myfun() called")

myfun=deco(myfun)





def deco2(fun2):
    def _deco2():
        print("before myfun2() called")
        fun2()
        print("after myfun2() called\n")
    return _deco2

@deco2
def myfun2():
    print("myfun2() called")
    return 'ok'

myfun2()










